Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to cloudevents sdk v2 #2243

Merged
merged 1 commit into from
Mar 21, 2020
Merged

Conversation

n3wscott
Copy link
Contributor

@n3wscott n3wscott commented Mar 18, 2020

fixes #2240

While I was here, I also refactored some of the CloudEvents integration, some major points:

  • you now send spec version 1.0 formatted events
  • ID is not the task run name, this was a bad idea if you want to send more than one event for that run. The task run name is now used as the subject.
  • ID is now a UUID.
  • The event that is created for sending is only created once, and then used for all deliveries. This means that all subscribers get the same event content and ID.
  • The event payload is marshaled inside the Event object. I show examples in the code and tests of how to set and get the payload as your custom struct.
  • Removed a lot of the layers passing clients and event components around. Better to build the event and then call send on the client directly. This deleted a lot of code that was doing many things, like create an event, and then attempt to send it.

I think the integration tests had been failing (will confirm in moments) because in the new SDK if you set data as a []byte, this tells us you want to base64 encode the data out. So the receiver was getting base64 encoded data and not understanding it.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Mar 18, 2020
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 18, 2020
@tekton-robot
Copy link
Collaborator

Hi @n3wscott. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 18, 2020
@dibyom
Copy link
Member

dibyom commented Mar 18, 2020

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 18, 2020
@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 18, 2020
@n3wscott
Copy link
Contributor Author

/retest

1 similar comment
@mattmoor
Copy link
Member

/retest

@n3wscott
Copy link
Contributor Author

The errors do not look related to my change...

/retest

@n3wscott
Copy link
Contributor Author

hm


Result | FAILURE
-- | --
Tests | 0 failed / 44 succeeded
Started | 2020-03-18 17:49 PDT
Elapsed | 48m18s

cool....

/retest

@n3wscott
Copy link
Contributor Author

/retest

i ... someone should make a better one of these.

@vdemeester
Copy link
Member

cc @afrittoli ^^
This tests has been flaky at some point, might be back to flaky with those changes

@dibyom
Copy link
Member

dibyom commented Mar 19, 2020

I0319 03:32:23.673]   status:
I0319 03:32:23.673]     cloudEvents:
I0319 03:32:23.673]     - status:
I0319 03:32:23.673]         condition: Failed
I0319 03:32:23.673]         message: "1 error occurred:\n\t* Post http://sink.default:8080: EOF\n\n"
I0319 03:32:23.673]         retryCount: 1
I0319 03:32:23.673]         sentAt: "2020-03-19T03:21:54Z"
I0319 03:32:23.674]       target: http://sink.default:8080
I0319 03:32:23.674]     completionTime: "2020-03-19T03:21:45Z"

@n3wscott
Copy link
Contributor Author

The sdk was not correctly setting the http request content length and was a real issue. Fixed with cloudevents/sdk-go#405

@mattmoor
Copy link
Member

Thanks for putting this together @n3wscott 🎉

@mattmoor
Copy link
Member

@vdemeester @dibyom @afrittoli What do we need to move this along? 😇

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/meow

/cc @sbwsg @bobcatfish

@tekton-robot tekton-robot requested a review from a user March 20, 2020 15:08
@tekton-robot
Copy link
Collaborator

@vdemeester: cat image

In response to this:

/meow

/cc @sbwsg @bobcatfish

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 20, 2020
Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!
My only question is whether we have less test coverage now.

failingClientBehaviour = FakeClientBehaviour{SendSuccessfully: false}
)

func TestSendCloudEvent(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this test all removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to wrap using the client send function. Just use the client directly.

logger = logger.With(zap.String("taskrun", tr.Name))

// Make the event we would like to send:
event, err := EventForTaskRun(tr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, you separated creating the event from the delivery. Is this so we only build it once, in case of multiple deliveries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the controller now uses the client directly, and all the custom stuff is doing is understanding how to take a TaskRun and turn it into an event.Event.

@n3wscott
Copy link
Contributor Author

My only question is whether we have less test coverage now.

Well... I deleted a lot of code, and so the coverage is about the same.

@afrittoli
Copy link
Member

My only question is whether we have less test coverage now.

Well... I deleted a lot of code, and so the coverage is about the same.

cool, thanks

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 20, 2020
@mattmoor
Copy link
Member

🙏 tide

@mattmoor
Copy link
Member

@afrittoli anything we can do to kick Prow here? Seems stuck.

@afrittoli afrittoli removed approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. labels Mar 20, 2020
@afrittoli
Copy link
Member

/lgtm
/approve

@tekton-robot tekton-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 20, 2020
@afrittoli
Copy link
Member

@afrittoli anything we can do to kick Prow here? Seems stuck.

{"base-sha":"212e3d47ae76ef5c059006cbd2c242963a6ca1a9","branch":"master","component":"tide","controller":"sync","error":"failed merging [2243]: [PR is unmergable. Do the Tide merge requirements match the GitHub settings for the repo? This branch can't be rebased]","file":"prow/tide/tide.go:357","func":"k8s.io/test-infra/prow/tide.(*Controller).Sync.func2","level":"error","msg":"Error syncing subpool.","org":"tektoncd","repo":"pipeline","time":"2020-03-20T22:37:51Z"}

That sounds... wierd

@afrittoli
Copy link
Member

@afrittoli anything we can do to kick Prow here? Seems stuck.

{"base-sha":"212e3d47ae76ef5c059006cbd2c242963a6ca1a9","branch":"master","component":"tide","controller":"sync","error":"failed merging [2243]: [PR is unmergable. Do the Tide merge requirements match the GitHub settings for the repo? This branch can't be rebased]","file":"prow/tide/tide.go:357","func":"k8s.io/test-infra/prow/tide.(*Controller).Sync.func2","level":"error","msg":"Error syncing subpool.","org":"tektoncd","repo":"pipeline","time":"2020-03-20T22:37:51Z"}

That sounds... wierd

@mattmoor @n3wscott The list of commits looks a bit unusual, there are 9 commits and at least on of them is a merge commit. Could you try and squash them into one or two commits, then I'll re-approve the patch? Thanks!

@afrittoli
Copy link
Member

/hold

@tekton-robot tekton-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed lgtm Indicates that a PR is ready to be merged. labels Mar 20, 2020
While I was here, I also refactored some of the CloudEvents integration, some major points:

you now send spec version 1.0 formatted events
ID is not the task run name, this was a bad idea if you want to send more than one event for that run. The task run name is now used as the subject.
ID is now a UUID.
The event that is created for sending is only created once, and then used for all deliveries. This means that all subscribers get the same event content and ID.
The event payload is marshaled inside the Event object. I show examples in the code and tests of how to set and get the payload as your custom struct.
Removed a lot of the layers passing clients and event components around. Better to build the event and then call send on the client directly. This deleted a lot of code that was doing many things, like create an event, and then attempt to send it.

Signed-off-by: Scott Nichols <[email protected]>
@n3wscott
Copy link
Contributor Author

ok smashed it all into one commit

/unhold

@mattmoor
Copy link
Member

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 20, 2020
@mattmoor
Copy link
Member

@afrittoli this should be RFAL

@n3wscott
Copy link
Contributor Author

looks like this failed:

 ERROR: test demo-pipeline-run-1=SucceededFalse but should be succeededtrue
I0320 23:33:53.708] ERROR: test demo-pipelinerun-with-resourcespec=SucceededFalse but should be succeededtrue
I0320 23:33:53.708]

/retest

@afrittoli
Copy link
Member

/lgtm
/approve

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 21, 2020
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afrittoli, vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [afrittoli,vdemeester]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@afrittoli
Copy link
Member

Thanks!

@tekton-robot tekton-robot merged commit fbde4aa into tektoncd:master Mar 21, 2020
@afrittoli afrittoli added the kind/misc Categorizes issue or PR as a miscellaneuous one. label Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit kind/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Cloud Events SDK changes things significantly
7 participants